/*
 * LogicView.java
 */

package logic;

import com.jgraph.layout.JGraphFacade;
import com.jgraph.layout.hierarchical.JGraphHierarchicalLayout;
import java.awt.Color;
import java.util.logging.Level;
import java.util.logging.Logger;
import javax.swing.text.BadLocationException;
import org.jdesktop.application.Action;
import org.jdesktop.application.ResourceMap;
import org.jdesktop.application.SingleFrameApplication;
import org.jdesktop.application.FrameView;
import org.jdesktop.application.TaskMonitor;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;


import java.util.Iterator;
import java.util.Map;
import javax.swing.Timer;
import javax.swing.Icon;
import javax.swing.JDialog;
import javax.swing.JFrame;
import javax.swing.JSlider;
import javax.swing.SwingConstants;
import javax.swing.event.ChangeEvent;
import javax.swing.event.ChangeListener;
import org.antlr.runtime.ANTLRStringStream;
import org.antlr.runtime.CharStream;
import org.antlr.runtime.CommonTokenStream;
import org.antlr.runtime.RecognitionException;

//import org.apache.batik.dom.GenericDOMImplementation;
import org.jgraph.JGraph;
import org.jgrapht.ext.JGraphModelAdapter;
import org.jgrapht.graph.DefaultDirectedGraph;

import portelogiche.PorteLogicheLexer;
import portelogiche.PorteLogicheParser;
import portelogiche.PorteLogicheSemantic;

/**
 * The application's main frame.
 */
public class LogicView extends FrameView {

   public DefaultDirectedGraph grafo = null;
   public  JGraph jgraph = null;
   LineNumberedBorder lnb = new LineNumberedBorder(0, 1);
   JGraphHierarchicalLayout layout = null;

    public LogicView(SingleFrameApplication app) {
        super(app);

        initComponents();

        // status bar initialization - message timeout, idle icon and busy animation, etc
        ResourceMap resourceMap = getResourceMap();
        int messageTimeout = resourceMap.getInteger("StatusBar.messageTimeout");
        messageTimer = new Timer(messageTimeout, new ActionListener() {
            public void actionPerformed(ActionEvent e) {
                statusMessageLabel.setText("");
            }
        });
        messageTimer.setRepeats(false);
        int busyAnimationRate = resourceMap.getInteger("StatusBar.busyAnimationRate");
        for (int i = 0; i < busyIcons.length; i++) {
            busyIcons[i] = resourceMap.getIcon("StatusBar.busyIcons[" + i + "]");
        }
        busyIconTimer = new Timer(busyAnimationRate, new ActionListener() {
            public void actionPerformed(ActionEvent e) {
                busyIconIndex = (busyIconIndex + 1) % busyIcons.length;
                statusAnimationLabel.setIcon(busyIcons[busyIconIndex]);
            }
        });
        idleIcon = resourceMap.getIcon("StatusBar.idleIcon");
        statusAnimationLabel.setIcon(idleIcon);
        progressBar.setVisible(false);

        // connecting action tasks to status bar via TaskMonitor
        TaskMonitor taskMonitor = new TaskMonitor(getApplication().getContext());
        taskMonitor.addPropertyChangeListener(new java.beans.PropertyChangeListener() {
            public void propertyChange(java.beans.PropertyChangeEvent evt) {
                String propertyName = evt.getPropertyName();
                if ("started".equals(propertyName)) {
                    if (!busyIconTimer.isRunning()) {
                        statusAnimationLabel.setIcon(busyIcons[0]);
                        busyIconIndex = 0;
                        busyIconTimer.start();
                    }
                    progressBar.setVisible(true);
                    progressBar.setIndeterminate(true);
                } else if ("done".equals(propertyName)) {
                    busyIconTimer.stop();
                    statusAnimationLabel.setIcon(idleIcon);
                    progressBar.setVisible(false);
                    progressBar.setValue(0);
                } else if ("message".equals(propertyName)) {
                    String text = (String)(evt.getNewValue());
                    statusMessageLabel.setText((text == null) ? "" : text);
                    messageTimer.restart();
                } else if ("progress".equals(propertyName)) {
                    int value = (Integer)(evt.getNewValue());
                    progressBar.setVisible(true);
                    progressBar.setIndeterminate(false);
                    progressBar.setValue(value);
                }
            }
        });
    }

    @Action
    public void showAboutBox() {
        if (aboutBox == null) {
            JFrame mainFrame = LogicApp.getApplication().getMainFrame();
            aboutBox = new LogicAboutBox(mainFrame);
            aboutBox.setLocationRelativeTo(mainFrame);
        }
        LogicApp.getApplication().show(aboutBox);
    }

    /** This method is called from within the constructor to
     * initialize the form.
     * WARNING: Do NOT modify this code. The content of this method is
     * always regenerated by the Form Editor.
     */
    // <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents
    private void initComponents() {

        mainPanel = new javax.swing.JPanel();
        jSplitPane1 = new javax.swing.JSplitPane();
        jSplitPane2 = new javax.swing.JSplitPane();
        jScrollPane2 = new javax.swing.JScrollPane();
        jTextArea1 = new javax.swing.JTextArea();
        jScrollPane4 = new javax.swing.JScrollPane();
        jTextPane1 = new javax.swing.JTextPane();
        jScrollPane1 = new javax.swing.JScrollPane();
        jPanel1 = new javax.swing.JPanel();
        jLabel1 = new javax.swing.JLabel();
        jSlider1 = new javax.swing.JSlider();
        jButton1 = new javax.swing.JButton();
        jButton2 = new javax.swing.JButton();
        jButton3 = new javax.swing.JButton();
        jCheckBox1 = new javax.swing.JCheckBox();
        jCheckBox2 = new javax.swing.JCheckBox();
        statusPanel = new javax.swing.JPanel();
        javax.swing.JSeparator statusPanelSeparator = new javax.swing.JSeparator();
        statusMessageLabel = new javax.swing.JLabel();
        statusAnimationLabel = new javax.swing.JLabel();
        progressBar = new javax.swing.JProgressBar();
        jLabel2 = new javax.swing.JLabel();
        jLabel3 = new javax.swing.JLabel();

        mainPanel.setName("mainPanel"); // NOI18N

        jSplitPane1.setBorder(null);
        jSplitPane1.setDividerLocation(270);
        jSplitPane1.setDividerSize(7);
        org.jdesktop.application.ResourceMap resourceMap = org.jdesktop.application.Application.getInstance(logic.LogicApp.class).getContext().getResourceMap(LogicView.class);
        jSplitPane1.setForeground(resourceMap.getColor("jSplitPane1.foreground")); // NOI18N
        jSplitPane1.setOrientation(javax.swing.JSplitPane.VERTICAL_SPLIT);
        jSplitPane1.setAutoscrolls(true);
        jSplitPane1.setContinuousLayout(true);
        jSplitPane1.setName("jSplitPane1"); // NOI18N
        jSplitPane1.setOneTouchExpandable(true);

        jSplitPane2.setBorder(null);
        jSplitPane2.setDividerSize(7);
        jSplitPane2.setContinuousLayout(true);
        jSplitPane2.setName("jSplitPane2"); // NOI18N
        jSplitPane2.setOneTouchExpandable(true);

        jScrollPane2.setName("jScrollPane2"); // NOI18N

        jTextArea1.setColumns(20);
        jTextArea1.setRows(5);
        jTextArea1.setText(resourceMap.getString("inputTextArea.text")); // NOI18N
        jTextArea1.setMinimumSize(new java.awt.Dimension(100, 100));
        jTextArea1.setName("inputTextArea"); // NOI18N
        jTextArea1.setVerifyInputWhenFocusTarget(false);
        jTextArea1.setBorder(lnb);
        jScrollPane2.setViewportView(jTextArea1);

        jSplitPane2.setLeftComponent(jScrollPane2);

        jScrollPane4.setName("jScrollPane4"); // NOI18N

        jTextPane1.setContentType(resourceMap.getString("jTextPane1.contentType")); // NOI18N
        jTextPane1.setEditable(false);
        jTextPane1.setDoubleBuffered(true);
        jTextPane1.setDragEnabled(false);
        jTextPane1.setFocusCycleRoot(false);
        jTextPane1.setFocusable(false);
        jTextPane1.setName("jTextPane1"); // NOI18N
        jTextPane1.setOpaque(false);
        jTextPane1.setRequestFocusEnabled(false);
        jTextPane1.setVerifyInputWhenFocusTarget(false);
        jScrollPane4.setViewportView(jTextPane1);

        jSplitPane2.setRightComponent(jScrollPane4);

        jSplitPane1.setTopComponent(jSplitPane2);

        jScrollPane1.setAutoscrolls(true);
        jScrollPane1.setDoubleBuffered(true);
        jScrollPane1.setName("jScrollPane1"); // NOI18N
        jScrollPane1.setRequestFocusEnabled(false);
        jScrollPane1.setVerifyInputWhenFocusTarget(false);
        jScrollPane1.setWheelScrollingEnabled(false);
        jSplitPane1.setRightComponent(jScrollPane1);

        jPanel1.setName("jPanel1"); // NOI18N

        jLabel1.setText(resourceMap.getString("jLabel1.text")); // NOI18N
        jLabel1.setName("jLabel1"); // NOI18N

        jSlider1.setMaximum(50);
        jSlider1.setMinimum(1);
        jSlider1.setPaintLabels(true);
        jSlider1.setToolTipText(resourceMap.getString("jSlider1.toolTipText")); // NOI18N
        jSlider1.setValue(10);
        jSlider1.setName("jSlider1"); // NOI18N
        jSlider1.setValueIsAdjusting(true);
        jSlider1.addChangeListener(new javax.swing.event.ChangeListener() {
            public void stateChanged(javax.swing.event.ChangeEvent evt) {
                jSlider1StateChanged(evt);
            }
        });

        org.jdesktop.layout.GroupLayout jPanel1Layout = new org.jdesktop.layout.GroupLayout(jPanel1);
        jPanel1.setLayout(jPanel1Layout);
        jPanel1Layout.setHorizontalGroup(
            jPanel1Layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING)
            .add(jPanel1Layout.createSequentialGroup()
                .addContainerGap()
                .add(jLabel1)
                .addPreferredGap(org.jdesktop.layout.LayoutStyle.RELATED)
                .add(jSlider1, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, 763, Short.MAX_VALUE))
        );
        jPanel1Layout.setVerticalGroup(
            jPanel1Layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING)
            .add(jPanel1Layout.createSequentialGroup()
                .add(12, 12, 12)
                .add(jLabel1, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, 78, Short.MAX_VALUE)
                .addContainerGap())
            .add(jSlider1, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, 110, Short.MAX_VALUE)
        );

        jSlider1.addChangeListener(new ChangeListener(){

            public void stateChanged(ChangeEvent event) {
                JSlider slider = (JSlider)event.getSource();
                // context.setFactor((float)slider.getValue()/40);
                //  view.refreshSizeChanged(slider.getValueIsAdjusting());
            }
        }

    );

    jButton1.setText(resourceMap.getString("start.text")); // NOI18N
    jButton1.setName("start"); // NOI18N
    jButton1.addMouseListener(new java.awt.event.MouseAdapter() {
        public void mouseReleased(java.awt.event.MouseEvent evt) {
            startMouseReleased(evt);
        }
    });

    jButton2.setText(resourceMap.getString("jButton2.text")); // NOI18N
    jButton2.setName("jButton2"); // NOI18N
    jButton2.addMouseListener(new java.awt.event.MouseAdapter() {
        public void mouseReleased(java.awt.event.MouseEvent evt) {
            jButton2MouseReleased(evt);
        }
    });

    jButton3.setText(resourceMap.getString("jButton3.text")); // NOI18N
    jButton3.setName("jButton3"); // NOI18N
    jButton3.addMouseListener(new java.awt.event.MouseAdapter() {
        public void mouseReleased(java.awt.event.MouseEvent evt) {
            jButton3MouseReleased(evt);
        }
    });

    jCheckBox1.setText(resourceMap.getString("jCheckBox1.text")); // NOI18N
    jCheckBox1.setName("jCheckBox1"); // NOI18N

    jCheckBox2.setText(resourceMap.getString("jCheckBox2.text")); // NOI18N
    jCheckBox2.setName("jCheckBox2"); // NOI18N

    org.jdesktop.layout.GroupLayout mainPanelLayout = new org.jdesktop.layout.GroupLayout(mainPanel);
    mainPanel.setLayout(mainPanelLayout);
    mainPanelLayout.setHorizontalGroup(
        mainPanelLayout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING)
        .add(org.jdesktop.layout.GroupLayout.TRAILING, jPanel1, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
        .add(jSplitPane1, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, 828, Short.MAX_VALUE)
        .add(mainPanelLayout.createSequentialGroup()
            .addContainerGap()
            .add(jButton1)
            .addPreferredGap(org.jdesktop.layout.LayoutStyle.UNRELATED)
            .add(jButton3)
            .addPreferredGap(org.jdesktop.layout.LayoutStyle.RELATED)
            .add(jCheckBox1)
            .addPreferredGap(org.jdesktop.layout.LayoutStyle.UNRELATED)
            .add(jCheckBox2)
            .addPreferredGap(org.jdesktop.layout.LayoutStyle.RELATED, 402, Short.MAX_VALUE)
            .add(jButton2))
    );
    mainPanelLayout.setVerticalGroup(
        mainPanelLayout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING)
        .add(mainPanelLayout.createSequentialGroup()
            .add(16, 16, 16)
            .add(mainPanelLayout.createParallelGroup(org.jdesktop.layout.GroupLayout.BASELINE)
                .add(jButton1)
                .add(jButton2)
                .add(jButton3)
                .add(jCheckBox1)
                .add(jCheckBox2))
            .addPreferredGap(org.jdesktop.layout.LayoutStyle.RELATED)
            .add(jSplitPane1, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, 508, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE)
            .addPreferredGap(org.jdesktop.layout.LayoutStyle.RELATED)
            .add(jPanel1, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
    );

    statusPanel.setName("statusPanel"); // NOI18N

    statusPanelSeparator.setName("statusPanelSeparator"); // NOI18N

    statusMessageLabel.setName("statusMessageLabel"); // NOI18N

    statusAnimationLabel.setHorizontalAlignment(javax.swing.SwingConstants.LEFT);
    statusAnimationLabel.setName("statusAnimationLabel"); // NOI18N

    progressBar.setName("progressBar"); // NOI18N

    jLabel2.setText(resourceMap.getString("jLabel2.text")); // NOI18N
    jLabel2.setName("jLabel2"); // NOI18N

    jLabel3.setText(resourceMap.getString("jLabel3.text")); // NOI18N
    jLabel3.setName("jLabel3"); // NOI18N

    org.jdesktop.layout.GroupLayout statusPanelLayout = new org.jdesktop.layout.GroupLayout(statusPanel);
    statusPanel.setLayout(statusPanelLayout);
    statusPanelLayout.setHorizontalGroup(
        statusPanelLayout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING)
        .add(statusPanelLayout.createSequentialGroup()
            .addContainerGap()
            .add(jLabel2)
            .add(33, 33, 33)
            .add(jLabel3)
            .add(19, 19, 19)
            .add(statusPanelLayout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING)
                .add(statusPanelLayout.createSequentialGroup()
                    .addPreferredGap(org.jdesktop.layout.LayoutStyle.RELATED, 579, Short.MAX_VALUE)
                    .add(progressBar, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE)
                    .add(31, 31, 31))
                .add(statusPanelLayout.createSequentialGroup()
                    .add(statusMessageLabel)
                    .addPreferredGap(org.jdesktop.layout.LayoutStyle.RELATED, 736, Short.MAX_VALUE)
                    .add(statusAnimationLabel)
                    .addContainerGap())))
        .add(statusPanelSeparator, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, 828, Short.MAX_VALUE)
    );
    statusPanelLayout.setVerticalGroup(
        statusPanelLayout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING)
        .add(statusPanelLayout.createSequentialGroup()
            .addContainerGap(20, Short.MAX_VALUE)
            .add(statusPanelLayout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING)
                .add(org.jdesktop.layout.GroupLayout.TRAILING, statusPanelLayout.createSequentialGroup()
                    .add(statusPanelSeparator, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE)
                    .add(20, 20, 20)
                    .add(statusPanelLayout.createParallelGroup(org.jdesktop.layout.GroupLayout.CENTER)
                        .add(jLabel2, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, 26, Short.MAX_VALUE)
                        .add(jLabel3, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
                    .addContainerGap())
                .add(org.jdesktop.layout.GroupLayout.TRAILING, statusPanelLayout.createSequentialGroup()
                    .add(progressBar, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE)
                    .addPreferredGap(org.jdesktop.layout.LayoutStyle.RELATED)
                    .add(statusPanelLayout.createParallelGroup(org.jdesktop.layout.GroupLayout.BASELINE)
                        .add(statusMessageLabel)
                        .add(statusAnimationLabel))
                    .add(20, 20, 20))))
    );

    setComponent(mainPanel);
    setStatusBar(statusPanel);
    }// </editor-fold>//GEN-END:initComponents

    private void startMouseReleased(java.awt.event.MouseEvent evt) {//GEN-FIRST:event_startMouseReleased
       // try {
            
        CharStream input;
       input = new ANTLRStringStream(jTextArea1.getText());

            if(input!=null&&input.size()!=0){
            try {
                PorteLogicheLexer lex = new PorteLogicheLexer(input);
                CommonTokenStream tokens = new CommonTokenStream(lex);
                PorteLogicheParser g = new PorteLogicheParser(tokens);
                PorteLogicheSemantic s = new PorteLogicheSemantic(g);
               
                try {
                 g.expr();
                 grafo = s.CheckTables();
                
                
                } catch (RecognitionException e) {
                    e.printStackTrace();
                }

                JGraphModelAdapter jgma = new JGraphModelAdapter(grafo);

                jgraph = new JGraph(jgma);
                jgraph.setEditable(false);
                jgraph.setDisconnectable(false);
                jgraph.setDisconnectOnMove(false);
                jgraph.setAutoResizeGraph(true);
                jgraph.setBendable(false);
                jgraph.scrollCellToVisible(jgraph.getRoots());

                JGraphFacade facade = new JGraphFacade(jgraph);
                layout = new JGraphHierarchicalLayout();
                facade.resetControlPoints();
                layout.setParallelEdgeSpacing(3);
                layout.setOrientation(SwingConstants.WEST);

                layout.setDeterministic(true);
                layout.setFineTuning(true);
                layout.setIntraCellSpacing(50);
                layout.setInterRankCellSpacing(60);
                layout.run(facade);
                Map nestedFacade = facade.createNestedMap(true, true);
                jgraph.getGraphLayoutCache().edit(nestedFacade);

                jScrollPane1.setViewportView(jgraph);
                jScrollPane1.updateUI();
             
                 
                 java.util.Calendar c = java.util.Calendar.getInstance();
                 int hh = c.get(java.util.Calendar.HOUR_OF_DAY);
                 int mm = c.get(java.util.Calendar.MINUTE);
                 int ss = c.get(java.util.Calendar.SECOND);
                  String time = hh + ":" + mm + ":" + ss; 

                jTextPane1.getDocument().insertString(jTextPane1.getCaretPosition(), time+" run: ", null);
                
                if(jCheckBox1.isSelected()){
                    
                Iterator<String> itr = s.msgArrayList.iterator();
                int u = 0;
                while (itr.hasNext()) {
                     String element = itr.next();
       
                jTextPane1.getDocument().insertString(jTextPane1.getCaretPosition(), element, null);

                }
                }
                if(jCheckBox2.isSelected()){
                jTextPane1.getDocument().insertString(jTextPane1.getCaretPosition(), "\n"+lex.LexerErrors.size()+" Scanner Errors:\n", null);
                
                jTextPane1.getDocument().insertString(jTextPane1.getCaretPosition(), lex.LexerErrors.toString(), null);
                
                jTextPane1.getDocument().insertString(jTextPane1.getCaretPosition(), "\n"+g.ParserErrors.size()+" Parser Errors:\n", null);
                jTextPane1.getDocument().insertString(jTextPane1.getCaretPosition(), g.ParserErrors.toString(), null);
                jTextPane1.getDocument().insertString(jTextPane1.getCaretPosition(), "\n"+s.SemanticErrors.size()+"Semantic Errors:\n", null);
                jTextPane1.getDocument().insertString(jTextPane1.getCaretPosition(), s.SemanticErrors.toString(), null);
                }
                

                
                if(!jCheckBox2.isSelected()){
                
                Iterator<String> itrLex = lex.LexerErrors.iterator();
                while (itrLex.hasNext()) {
                     String elementL = itrLex.next();
                
                jTextPane1.getDocument().insertString(jTextPane1.getCaretPosition(), "\n"+elementL+"\n", null);

                }
               
               Iterator<String> itrPar = g.ParserErrors.iterator();
                while (itrPar.hasNext()) {
                     String elementP = itrPar.next();

                jTextPane1.getDocument().insertString(jTextPane1.getCaretPosition(), "\n"+elementP+"\n", null);

                }
                
               Iterator<String> itrSem = s.checkArrayList.iterator();
                while (itrSem.hasNext()) {
                     String elementS = itrSem.next();

                jTextPane1.getDocument().insertString(jTextPane1.getCaretPosition(), "\n"+elementS+"\n", null);

                }
                }
                
               Integer errorCount = lex.LexerErrors.size()+g.ParserErrors.size()+s.SemanticErrors.size();
               Integer portCount = g.Ports.size();

               jLabel3.setForeground(Color.decode("#007700"));
               jLabel3.setText(portCount.toString()+" Ports");
               if(errorCount<=0){
               jLabel2.setForeground(Color.decode("#007700"));
               jLabel2.setText("Well done !");
               }
               else{
               jLabel2.setForeground(Color.RED);
               jLabel2.setText(errorCount.toString()+" Errors");
               }
            
                
                if (lex.LexerErrors.isEmpty()&&g.ParserErrors.isEmpty()&&s.SemanticErrors.isEmpty()){
                jTextPane1.getDocument().insertString(jTextPane1.getCaretPosition(), "\nWell Done !\n", null);    
                }
                
            } catch (BadLocationException ex) {
                Logger.getLogger(LogicView.class.getName()).log(Level.SEVERE, null, ex);
            }

            
            
            }  
            else{
               jTextPane1.setText("Empty input\n");
            }
        
        
        
}//GEN-LAST:event_startMouseReleased

    private void jButton2MouseReleased(java.awt.event.MouseEvent evt) {//GEN-FIRST:event_jButton2MouseReleased

        jTextPane1.setText(null);

    }//GEN-LAST:event_jButton2MouseReleased

    private void jSlider1StateChanged(javax.swing.event.ChangeEvent evt) {//GEN-FIRST:event_jSlider1StateChanged
        // TODO add your handling code here:
        
      if(jgraph!=null){
           double val = jSlider1.getValue();
           
           jgraph.setScale(val/10);
           jScrollPane1.setViewportView(jgraph);
           jScrollPane1.updateUI();
        }
        
        
        
        
    }//GEN-LAST:event_jSlider1StateChanged

    private void jButton3MouseReleased(java.awt.event.MouseEvent evt) {//GEN-FIRST:event_jButton3MouseReleased


  /*      int inset=0;
 
Object[] cells = jgraph.getRoots(); 
Rectangle2D bounds = jgraph.toScreen(jgraph.getCellBounds(cells)); 
if (bounds != null) { 
// Constructs the svg generator used for painting the graph to 
            Writer writer = null;
            try {
                DOMImplementation domImpl = GenericDOMImplementation.getDOMImplementation();
                SVGGraphics2D svgGenerator = new SVGGraphics2D(domImpl.createDocument(null, "svg", null));
                svgGenerator.translate(-bounds.getX() + inset, -bounds.getY() + inset);
                RepaintManager currentManager = RepaintManager.currentManager(jgraph);
                currentManager.setDoubleBufferingEnabled(false);
                jgraph.paint(svgGenerator);
                writer = new OutputStreamWriter(System.out, "UTF-8");
                svgGenerator.stream(writer, false);
                currentManager.setDoubleBufferingEnabled(true);
            } catch (SVGGraphics2DIOException ex) {
                Logger.getLogger(LogicView.class.getName()).log(Level.SEVERE, null, ex);
            } catch (UnsupportedEncodingException ex) {
                Logger.getLogger(LogicView.class.getName()).log(Level.SEVERE, null, ex);
            } finally {
                try {
                    writer.close();
                } catch (IOException ex) {
                    Logger.getLogger(LogicView.class.getName()).log(Level.SEVERE, null, ex);
                }
            }

} 
*/
        
        // TODO add your handling code here:
    }//GEN-LAST:event_jButton3MouseReleased

    

    // Variables declaration - do not modify//GEN-BEGIN:variables
    private javax.swing.JButton jButton1;
    private javax.swing.JButton jButton2;
    private javax.swing.JButton jButton3;
    private javax.swing.JCheckBox jCheckBox1;
    private javax.swing.JCheckBox jCheckBox2;
    private javax.swing.JLabel jLabel1;
    private javax.swing.JLabel jLabel2;
    private javax.swing.JLabel jLabel3;
    private javax.swing.JPanel jPanel1;
    public javax.swing.JScrollPane jScrollPane1;
    private javax.swing.JScrollPane jScrollPane2;
    private javax.swing.JScrollPane jScrollPane4;
    private javax.swing.JSlider jSlider1;
    private javax.swing.JSplitPane jSplitPane1;
    private javax.swing.JSplitPane jSplitPane2;
    private javax.swing.JTextArea jTextArea1;
    private javax.swing.JTextPane jTextPane1;
    private javax.swing.JPanel mainPanel;
    private javax.swing.JProgressBar progressBar;
    private javax.swing.JLabel statusAnimationLabel;
    private javax.swing.JLabel statusMessageLabel;
    private javax.swing.JPanel statusPanel;
    // End of variables declaration//GEN-END:variables

    private final Timer messageTimer;
    private final Timer busyIconTimer;
    private final Icon idleIcon;
    private final Icon[] busyIcons = new Icon[15];
    private int busyIconIndex = 0;

    private JDialog aboutBox;
}
